using System.Collections.ObjectModel;
using HMCollada.Core;
using HMCollada.FX;
using System.Xml;

namespace HMCollada.FX {
    internal struct HMColladaProfileCOMMON {
        internal string id;
        internal HMColladaAsset asset;
        internal Collection<HMColladaImage> image;
        internal Collection<HMColladaNewParam> newparam;
        internal HMColladaTechnique technique;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        private static HMColladaProfileCOMMON LoadProfileCOMMON() {
            HMColladaProfileCOMMON newProfile = new HMColladaProfileCOMMON();
            newProfile.id = colladaReader.GetAttribute("id");

            newProfile.image = new Collection<HMColladaImage>();
            newProfile.newparam = new Collection<HMColladaNewParam>();

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "asset": newProfile.asset = LoadAsset(); break;
                        case "image": newProfile.image.Add(LoadImage()); break;
                        case "newparam": newProfile.newparam.Add(LoadNewParam()); break;
                        case "technique": newProfile.technique = LoadTechnique(); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "profile_COMMON");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newProfile;
        }
    }
}